import app
import  requests



class OrderApi(object):

    def __init__(self):
        self.user_order_url = app.URL + "/api/v1/order/by_user"
        self.create_order_url = app.URL + "/api/v1/order"
        self.select_order_url = app.URL + "/api/v1/order/{}"
  
    def get_uer_order(self):
        param = {"page":app.page}
        header = app.header
        return  requests.get(self.user_order_url,headers=header,params=param)
        
    def create_order(self):
        header = app.header
        data = {"products":[{"product_id":8,"count":1},{"product_id":10,"count":2}]}
        return  requests.post(self.create_order_url,headers=header,json=data)

    def  select_order(self):
        header = app.header
        url = self.select_order_url.format(app.order_id)
        return  requests.get(url,headers=header)